package org.mcclone.splitter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * @author McClone
 */
public class Splitter {

    public static final Logger logger = LoggerFactory.getLogger(Splitter.class);

    private Integer size;

    public Splitter(int size) {
        this.size = size;
    }

    protected Splitter execute(File file) {
        throw new UnsupportedOperationException();
    }

    protected Integer getSize() {
        return size;
    }

    protected Splitter setSize(Integer size) {
        this.size = size;
        return this;
    }

    public static Splitter on(int size) {
        return new Splitter(size);
    }

    public void txt(File file, String destDir, String encoding) {
        new TxtSplitter(getSize()).setEncoding(encoding).setDestDir(destDir).execute(file);
    }

    public void txt(String file, String destDir, String encoding) {
        new TxtSplitter(getSize()).setEncoding(encoding).setDestDir(destDir).execute(new File(file));
    }

    public TxtSplitter txt() {
        return new TxtSplitter(getSize());
    }
}
